home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / hp16c.emu < prev    next >
Text File  |  1995-03-23  |  3KB  |  210 lines

  1. Article 1641 of comp.sys.handhelds:
  2. From: fin@norge.unet.umn.edu (Craig A. Finseth)
  3. Subject: HP-16 emulator
  4. Date: 27 Mar 90 21:35:45 GMT
  5. Organization: Univ Netw Serv, Univ of Minn
  6.  
  7. Here is my HP-16 emulator code.  No, it doesn't do quite everything
  8. but it does use the vectored Enter key to add "#" characters...
  9. ------------------------------------------------------------
  10. Written by: Craig Finseth, University of Minnesota
  11. From: 24 Mar 1990
  12. What: Partial HP-16C Emulator
  13.  
  14. ON16    Turn on our special ENTER key.
  15. OFF16    Turn off our special ENTER key.
  16. BASE    MATH:BASE menu.
  17. LJ    Left Justify
  18. MSKL    Mask Left
  19. MSKR    Mask Right
  20.  
  21. RLn    Rotate Left by n
  22. RRn    Rotate Right by n
  23. RLC    Rotate Left through Carry
  24. RRC    Rotate Right through Carry
  25. RLCn    Rotate Left by n through Carry
  26. RRCn    Rotate Right by n through Carry
  27.  
  28. CNTB    Count the number of "1" bits
  29. SB    Set a bit
  30. CB    Clear a bit
  31. TB    Test a bit
  32. TOBIN    Convert an expression to a binary number.
  33. TOREAL    Convert an expression to a real number.
  34.  
  35. TRIMN    Trim N to the current word size.
  36. SWAPC    Swap the bottom bit of the current value with the carry bit.
  37. CARRY    The carry bit.
  38. alphaENTER    Our vectored Enter key.  This key checks to see if the
  39.         first character of the command string is a digit ("0"
  40.         through "9").  If so, it prepends a "#" character to the
  41.         command line.
  42.  
  43.         Note: The USER mode must be active for this to work.
  44.  
  45. HP-16C Functions Not Emulated:
  46.  
  47.     RMD
  48.     DBLR
  49.     DBL/
  50.     DBL*
  51.     1's mode
  52.     UNSGN mode
  53.  
  54. All other HP-16C functions exist in the HP-48SX (e.g., RR, RL, ASR) or
  55. are implemented in a better way in the HP-48SX (e.g., program
  56. control).
  57.  
  58. Checksum: #17d
  59. Size: 1420.5
  60. ------------------------------------------------------------
  61. %%HP: T(3)A(D)F(.);
  62. DIR
  63.   ON16
  64.     \<< -62 SF -63 SF
  65.     \>>
  66.   OFF16
  67.     \<< -62 CF -63 CF
  68.     \>>
  69.   BASE
  70.     \<< 9 MENU
  71.     \>>
  72.   LJ
  73.     \<< DUP
  74.       IF TOREAL
  75.       THEN TOBIN
  76.         DO RL DUP
  77.         UNTIL # 1d
  78. AND TOREAL
  79.         END RR
  80.       ELSE # 0d
  81.       END
  82.     \>>
  83.   MSKL
  84.     \<< TRIMN \-> n
  85.       \<< # 0d 1 n
  86.         START RR
  87. # 1d RR OR
  88.         NEXT
  89.       \>>
  90.     \>>
  91.   MSKR
  92.     \<< TRIMN \-> n
  93.       \<< # 0d 1 n
  94.         START SL
  95. # 1d OR
  96.         NEXT
  97.       \>>
  98.     \>>
  99.   RLn
  100.     \<< \-> X n
  101.       \<< X TOBIN 1 n
  102. TRIMN
  103.         START RL
  104.         NEXT
  105.       \>>
  106.     \>>
  107.   RRn
  108.     \<< \-> X n
  109.       \<< X TOBIN 1 n
  110. TRIMN
  111.         START RR
  112.         NEXT
  113.       \>>
  114.     \>>
  115.   RLC
  116.     \<< TOBIN RL
  117. SWAPC
  118.     \>>
  119.   RRC
  120.     \<< TOBIN SWAPC
  121. RR
  122.     \>>
  123.   RLCn
  124.     \<< \-> X n
  125.       \<< X TOBIN 1 n
  126. TRIMN
  127.         START RLC
  128.         NEXT
  129.       \>>
  130.     \>>
  131.   RRCn
  132.     \<< \-> X n
  133.       \<< X TOBIN 1 n
  134. TRIMN
  135.         START RRC
  136.         NEXT
  137.       \>>
  138.     \>>
  139.   CNTB
  140.     \<< 0 SWAP TOBIN
  141. 1 RCWS
  142.       START
  143.         IF DUP # 1d
  144. AND TOREAL
  145.         THEN SWAP 1
  146. + SWAP
  147.         END RR
  148.       NEXT DROP
  149.     \>>
  150.   SB
  151.     \<< # 1d SWAP RLn
  152. OR
  153.     \>>
  154.   CB
  155.     \<< # 1d NOT SWAP
  156. RLn AND
  157.     \>>
  158.   TB
  159.     \<< RRn # 1d AND
  160.     \>>
  161.   TOBIN
  162.     \<< \->NUM \-> X
  163.       \<<
  164.         IF X TYPE
  165. 10 \=/
  166.         THEN X RE
  167. R\->B
  168.         ELSE X
  169.         END
  170.       \>>
  171.     \>>
  172.   TOREAL
  173.     \<< \->NUM \-> X
  174.       \<<
  175.         IF X TYPE
  176. 10 ==
  177.         THEN X B\->R
  178.         ELSE X
  179.         END
  180.       \>>
  181.     \>>
  182.   TRIMN
  183.     \<< TOREAL ABS
  184. RCWS MOD
  185.     \>>
  186.   SWAPC
  187.     \<< DUP CARRY
  188. SWAP # 1d AND
  189. 'CARRY' STO SWAP
  190. # 1d NOT AND OR
  191.     \>>
  192.   CARRY # 0d
  193.   \GaENTER
  194.     \<< \-> X
  195.       \<< X 1 1 SUB
  196. NUM \-> Y
  197.         \<<
  198.           IF Y 48 \>=
  199. Y 57 \<= AND
  200.           THEN "#"
  201. X +
  202.           ELSE X
  203.           END
  204.         \>>
  205.       \>> OBJ\->
  206.     \>>
  207. END
  208.  
  209.  
  210.